<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">
         
        <ui:define name="content">
             <br />
            
            <p:panel header="Back Orders" id="order" toggleable="true">
                <h:form prependId="false">
                    <h:panelGroup id="messagePanel" layout="block">
                        <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                    </h:panelGroup>
                   
                    <h:panelGroup rendered="#{backorderEntityController.items.rowCount > 0}">
                        <p:dataTable value="#{backorderEntityController.items}" 
                                     var="item" style="text-align: center"
                                     paginator="true" rows="10"  
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                     rowsPerPageTemplate="5,10,15">
                            
                            <p:column filterBy="#{item.id}">
                                <f:facet name="header">
                                    <h:outputText value="ID"/>
                                </f:facet>
                                <h:outputText value="#{item.id}"/>
                            </p:column>      
                            
                            <p:column filterBy="#{backorderEntityController.formatter.format(item.requiredLeadTime)}">
                                <f:facet name="header">
                                    <h:outputText value="Required Delivery Date"/>
                                </f:facet>
                                <h:outputText value="#{backorderEntityController.formatter.format(item.requiredLeadTime)}"/>
                            </p:column> 
                            
                            <p:column filterBy="#{item.confirmedLeadTime}">
                                <f:facet name="header">
                                    <h:outputText value="Calculated Delivery Date"/>
                                </f:facet>
                                <h:outputText value="#{backorderEntityController.formatter.format(item.confirmedLeadTime)}" rendered="#{item.confirmedLeadTime!=null}"/>
                            </p:column>
                            
                            <p:column filterBy="#{item.status}">
                                <f:facet name="header">
                                    <h:outputText value="status"/>
                                </f:facet>
                                <h:outputText value="#{item.status}"/>
                            </p:column>
                            
                            
                            
<!--                            <p:column filterBy="#{item.mrpCheckStatus}" >
                                <f:facet name="header">
                                    <h:outputText value="MrpCheckStatus" />
                                </f:facet>
                                <h:outputText value="#{item.mrpCheckStatus}"/>
                            </p:column>-->
                            
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="&nbsp;"/>
                                </f:facet>
                                <p:menuButton value="Options" >
                                     <p:menuitem value=" ATP check" ajax="false" 
                                                action="#{backorderEntityController.atpCheck}" rendered="#{loginBacking.editBackOrder and !backorderEntityController.isCancelled(item)}"/>
                               
                                     <p:menuitem value=" View" ajax="false" rendered="#{ loginBacking.listAllBackOrders}" 
                                                action="#{backorderEntityController.prepareView}"/> 
                                     
                                     <p:menuitem value=" Approve" ajax="false" rendered="#{loginBacking.editBackOrder and item.mrpCheckStatus!=null and !backorderEntityController.isConfirmed(item)}" 
                                                action="#{backorderEntityController.approveAtp(item)}"/> 
                                     
                                     <p:menuitem value=" Cancel" ajax="false" rendered="#{loginBacking.editBackOrder and !backorderEntityController.isCancelled(item) }" 
                                                action="#{backorderEntityController.cancelOrder(item)}"/> 
                                      
                                </p:menuButton>
                                
                            </p:column>
                           
                        </p:dataTable>   
                    </h:panelGroup>
                    <br />
                </h:form>
            </p:panel>
             
             <br/>
             
        </ui:define>
    </ui:composition>

</html>
